package cn.edu.sgu.www.mhxysy.controller;

import cn.edu.sgu.www.mhxysy.consts.MimeType;
import cn.edu.sgu.www.mhxysy.entity.SchoolFounder;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.SchoolFounderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author heyunlin
 * @version 1.0
 */
@RestController
@RequestMapping(path = "/school_founder", produces = MimeType.APPLICATION_JSON_CHARSET_UTF_8)
public class SchoolFounderController {

	private final SchoolFounderService schoolFounderService;

	@Autowired
	public SchoolFounderController(SchoolFounderService schoolFounderService) {
		this.schoolFounderService = schoolFounderService;
	}

	@RequestMapping(value = "/selectAll", method = RequestMethod.GET)
	public JsonResult<List<SchoolFounder>> selectAll() {
		List<SchoolFounder> list = schoolFounderService.selectAll();

		return JsonResult.success(null, list);
	}

	@RequestMapping(value = "/selectNameById", method = RequestMethod.GET)
	public JsonResult<String> selectNameById(@RequestParam Integer id) {
		String name = schoolFounderService.selectNameById(id);

		return JsonResult.success(null, name);
	}

}